<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="3.0.0">
  <annotation>
    <appinfo source="urn:opengis:specification:gml:schema-xsd:coverage:v3.0.0">coverage.xsd</appinfo>
    <documentation xml:lang="en"> GML Coverage schema. 
    Copyright (c) 2002 OGC, All Rights Reserved.
    </documentation>
  </annotation>
  <!-- ==============================================================
       includes and imports
	============================================================== -->
  <include schemaLocation="feature.xsd"/>
  <include schemaLocation="valueObjects.xsd"/>
  <include schemaLocation="grids.xsd"/>
  <include schemaLocation="geometryAggregates.xsd"/>
  <!-- ==============================================================
       global types and elements
	============================================================== -->
  <!-- ================= Abstract coverage definition ================== -->
  <!-- =========================================================== -->
  <!-- =========================================================== -->
  <element name="_Coverage" type="gml:AbstractCoverageType" abstract="true" substitutionGroup="gml:_Feature"/>
  <!-- =========================================================== -->
  <complexType name="AbstractCoverageType" abstract="true">
    <annotation>
      <documentation>A coverage is a set of attribute values (its range) associated to position within a bounded space (its domain). This coverage uses a single coverage function to associate an element from the domain with an element from its range.  This definition conforms to ISO 19123.  Note that coverage is a GML feature.</documentation>
    </annotation>
    <complexContent>
      <extension base="gml:AbstractFeatureType">
        <sequence>
          <element ref="gml:domainSet"/>
          <element ref="gml:rangeSet"/>
          <element ref="gml:coverageFunction" minOccurs="0"/>
        </sequence>
        <attribute name="dimension" type="positiveInteger" use="optional"/>
      </extension>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="domainSet" type="gml:DomainSetType"/>
  <!-- =========================================================== -->
  <complexType name="DomainSetType">
    <annotation>
      <documentation>The spatiotemporal domain of a coverage.  
  Typically 
  * a geometry collection, 
  * an implicit geometry (e.g. a grid), 
  * an explicit or implicit collection of time instances or periods, or
  * the geometries associated with a feature collection.  

N.B. Temporal domains still to be implemented.</documentation>
    </annotation>
    <choice minOccurs="0">
      <element ref="gml:_Geometry"/>
      <element ref="gml:_TimeObject"/>
    </choice>
    <attributeGroup ref="gml:AssociationAttributeGroup"/>
  </complexType>
  <!-- =========================================================== -->
  <element name="rangeSet" type="gml:RangeSetType"/>
  <!-- =========================================================== -->
  <complexType name="RangeSetType">
    <choice>
      <choice maxOccurs="unbounded">
        <element ref="gml:ValueArray">
          <annotation>
            <documentation>each member _Value holds a tuple or "row" from the equivalent table</documentation>
          </annotation>
        </element>
        <element ref="gml:_ScalarValueList">
          <annotation>
            <documentation>each list holds the complete set of one scalar component from the values - i.e. a "column" from the equivalent table</documentation>
          </annotation>
        </element>
      </choice>
      <element ref="gml:DataBlock">
        <annotation>
          <documentation>Its tuple list holds the values as space-separated tuples each of which contains comma-separated components, and the tuple structure is specified using the rangeParameters property.  
</documentation>
        </annotation>
      </element>
      <element ref="gml:File">
        <annotation>
          <documentation>a reference to an external source for the data, together with a description of how that external source is structured
</documentation>
        </annotation>
      </element>
    </choice>
  </complexType>
  <!-- =========================================================== -->
  <element name="coverageFunction" type="gml:CoverageFunctionType"/>
  <!-- =========================================================== -->
  <complexType name="CoverageFunctionType">
    <annotation>
      <documentation>
      The function or rule which defines the map from members of the domainSet to the range.  
      More functions will be added to this list
    </documentation>
    </annotation>
    <choice>
      <element ref="gml:MappingRule"/>
      <element ref="gml:GridFunction"/>
    </choice>
  </complexType>
  <!-- =========================================================== -->
  <!-- ============== Components for encoding the rangeSet ============= -->
  <!-- =========================================================== -->
  <element name="DataBlock" type="gml:DataBlockType"/>
  <!-- =========================================================== -->
  <complexType name="DataBlockType">
    <sequence>
      <element ref="gml:rangeParameters"/>
      <element ref="gml:tupleList"/>
    </sequence>
  </complexType>
  <!-- =========================================================== -->
  <element name="tupleList" type="gml:CoordinatesType"/>
  <!-- =========================================================== -->
  <element name="File" type="gml:FileType"/>
  <!-- =========================================================== -->
  <complexType name="FileType">
    <sequence>
      <element ref="gml:rangeParameters"/>
      <element name="fileName" type="anyURI"/>
      <element name="fileStructure" type="gml:FileValueModelType"/>
      <element name="mimeType" type="anyURI" minOccurs="0"/>
      <element name="compression" type="anyURI" minOccurs="0"/>
    </sequence>
  </complexType>
  <!-- =========================================================== -->
  <simpleType name="FileValueModelType">
    <annotation>
      <documentation>List of codes that identifies the file structure model for records stored in files.</documentation>
    </annotation>
    <restriction base="string">
      <enumeration value="Record Interleaved"/>
    </restriction>
  </simpleType>
  <!-- =========================================================== -->
  <element name="rangeParameters" type="gml:RangeParametersType"/>
  <!-- =========================================================== -->
  <complexType name="RangeParametersType">
    <annotation>
      <documentation>
      Metadata about the rangeSet.  Definition of record structure.   
      This is required if the rangeSet is encoded in a DataBlock.  
      We use a gml:_Value with empty values as a map of the composite value structure.</documentation>
    </annotation>
    <sequence minOccurs="0">
      <element ref="gml:_Value"/>
    </sequence>
    <attributeGroup ref="gml:AssociationAttributeGroup"/>
  </complexType>
  <!-- =========================================================== -->
  <!-- ============= Components for coverageFunctions ================ -->
  <!-- =========================================================== -->
  <element name="MappingRule" type="gml:StringOrRefType">
    <annotation>
      <documentation>Description of a rule for associating members from the domainSet with members of the rangeSet.  </documentation>
    </annotation>
  </element>
  <!-- =========================================================== -->
  <element name="GridFunction" type="gml:GridFunctionType"/>
  <!-- =========================================================== -->
  <complexType name="GridFunctionType">
    <annotation>
      <documentation>Defines how values in the domain are mapped to the range set. The start point and the sequencing rule are specified here.</documentation>
    </annotation>
    <sequence>
      <element name="sequenceRule" type="gml:SequenceRuleType" minOccurs="0">
        <annotation>
          <documentation>If absent, the implied value is "Linear".</documentation>
        </annotation>
      </element>
      <element name="startPoint" type="gml:integerList" minOccurs="0">
        <annotation>
          <documentation>Index position of the first grid post.  If absent the startPoint is equal to the value of gridEnvelope::low from the grid definition.  </documentation>
        </annotation>
      </element>
    </sequence>
  </complexType>
  <!-- =========================================================== -->
  <element name="IndexMap" type="gml:IndexMapType" substitutionGroup="gml:GridFunction"/>
  <!-- =========================================================== -->
  <complexType name="IndexMapType">
    <annotation>
      <documentation>Exends GridFunctionType with a lookUpTable.  This contains a list of indexes of members within the rangeSet corresponding with the members of the domainSet.  The domainSet is traversed in list order if it is enumerated explicitly, or in the order specified by a SequenceRule if the domain is an implicit set.    The length of the lookUpTable corresponds with the length of the subset of the domainSet for which the coverage is defined.  </documentation>
    </annotation>
    <complexContent>
      <extension base="gml:GridFunctionType">
        <sequence>
          <element name="lookUpTable" type="gml:integerList"/>
        </sequence>
      </extension>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <complexType name="SequenceRuleType">
    <simpleContent>
      <extension base="gml:SequenceRuleNames">
        <attribute name="order" type="gml:IncrementOrder" use="optional"/>
      </extension>
    </simpleContent>
  </complexType>
  <!-- =========================================================== -->
  <simpleType name="SequenceRuleNames">
    <annotation>
      <documentation>List of codes (adopted from ISO 19123 Annex C) that identifies the rule for traversing a grid to correspond with the sequence of members of the rangeSet.</documentation>
    </annotation>
    <restriction base="string">
      <enumeration value="Linear"/>
      <enumeration value="Boustrophedonic"/>
      <enumeration value="Cantor-diagonal"/>
      <enumeration value="Spiral"/>
      <enumeration value="Morton"/>
      <enumeration value="Hilbert"/>
    </restriction>
  </simpleType>
  <!-- =========================================================== -->
  <simpleType name="IncrementOrder">
    <annotation>
      <documentation>The enumeration value here indicates the incrementation order  to be used on the first 2 axes, i.e. "+x-y" means that the points on the first axis are to be traversed from lowest to highest and  the points on the second axis are to be traversed from highest to lowest. The points on all other axes (if any) beyond the first 2 are assumed to increment from lowest to highest.</documentation>
    </annotation>
    <restriction base="string">
      <enumeration value="+x+y"/>
      <enumeration value="+y+x"/>
      <enumeration value="+x-y"/>
      <enumeration value="-x-y"/>
    </restriction>
  </simpleType>
  <!-- =========================================================== -->
  <!-- == Specialised Coverage types - typed by the structure of the domain set == -->
  <!-- =========================================================== -->
  <element name="MultiPointCoverage" type="gml:MultiPointCoverageType" substitutionGroup="gml:_Coverage"/>
  <!-- =========================================================== -->
  <complexType name="MultiPointCoverageType">
    <annotation>
      <documentation>A discrete coverage type whose domain is defined by a collection of point
			</documentation>
    </annotation>
    <complexContent>
      <restriction base="gml:AbstractCoverageType">
        <sequence>
          <element ref="gml:multiPointDomain"/>
          <element ref="gml:rangeSet"/>
          <element ref="gml:coverageFunction" minOccurs="0"/>
        </sequence>
        <attribute name="dimension" type="positiveInteger" use="required"/>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="multiPointDomain" type="gml:MultiPointDomainType" substitutionGroup="gml:domainSet"/>
  <!-- =========================================================== -->
  <complexType name="MultiPointDomainType">
    <complexContent>
      <restriction base="gml:DomainSetType">
        <sequence minOccurs="0">
          <element ref="gml:MultiPoint"/>
        </sequence>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="MultiSurfaceCoverage" type="gml:MultiSurfaceCoverageType" substitutionGroup="gml:_Coverage"/>
  <!-- =========================================================== -->
  <complexType name="MultiSurfaceCoverageType">
    <annotation>
      <documentation>A discrete coverage type whose domain is defined by a collection of surface patches (includes polygons, triangles, rectangles, etc). 
			</documentation>
    </annotation>
    <complexContent>
      <restriction base="gml:AbstractCoverageType">
        <sequence>
          <element ref="gml:multiSurfaceDomain"/>
          <element ref="gml:rangeSet"/>
          <element ref="gml:coverageFunction" minOccurs="0"/>
        </sequence>
        <attribute name="dimension" type="positiveInteger" use="required"/>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="multiSurfaceDomain" type="gml:MultiSurfaceDomainType" substitutionGroup="gml:domainSet"/>
  <!-- =========================================================== -->
  <complexType name="MultiSurfaceDomainType">
    <complexContent>
      <restriction base="gml:DomainSetType">
        <sequence minOccurs="0">
          <element ref="gml:MultiSurface"/>
        </sequence>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="GridCoverage" type="gml:GridCoverageType" substitutionGroup="gml:_Coverage"/>
  <!-- =========================================================== -->
  <complexType name="GridCoverageType">
    <complexContent>
      <restriction base="gml:AbstractCoverageType">
        <sequence>
          <element ref="gml:gridDomain"/>
          <element ref="gml:rangeSet"/>
          <element ref="gml:coverageFunction" minOccurs="0"/>
        </sequence>
        <attribute name="dimension" type="positiveInteger" use="required"/>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="gridDomain" type="gml:GridDomainType" substitutionGroup="gml:domainSet"/>
  <!-- =========================================================== -->
  <complexType name="GridDomainType">
    <complexContent>
      <restriction base="gml:DomainSetType">
        <choice minOccurs="0">
          <element ref="gml:Grid"/>
        </choice>
        <attributeGroup ref="gml:AssociationAttributeGroup"/>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="RectifiedGridCoverage" type="gml:RectifiedGridCoverageType" substitutionGroup="gml:_Coverage"/>
  <!-- =========================================================== -->
  <complexType name="RectifiedGridCoverageType">
    <complexContent>
      <restriction base="gml:AbstractCoverageType">
        <sequence>
          <element ref="gml:rectifiedGridDomain"/>
          <element ref="gml:rangeSet"/>
          <element ref="gml:coverageFunction" minOccurs="0"/>
        </sequence>
        <attribute name="dimension" type="positiveInteger" use="required"/>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
  <element name="rectifiedGridDomain" type="gml:RectifiedGridDomainType" substitutionGroup="gml:domainSet"/>
  <!-- =========================================================== -->
  <complexType name="RectifiedGridDomainType">
    <complexContent>
      <restriction base="gml:DomainSetType">
        <choice minOccurs="0">
          <element ref="gml:RectifiedGrid"/>
        </choice>
        <attributeGroup ref="gml:AssociationAttributeGroup"/>
      </restriction>
    </complexContent>
  </complexType>
  <!-- =========================================================== -->
</schema>
